/**
 * @description 力扣1732
 * @param {number[]} gain
 * @return {number}
 */
var largestAltitude = function (gain) {
    let result = [0];
    for (let i = 0; i < gain.length; i++) {
        result.push(gain[i] + result[result.length - 1])
    }
    return result.sort((a, b) => b - a)[0]
};
console.log(largestAltitude([-5, 1, 5, 0, -7]));